package cn.tedu.luban.order.main.repository.impl;

import cn.tedu.luban.order.main.converter.OrderConverter;
import cn.tedu.luban.order.main.converter.OrderLogConverter;
import cn.tedu.luban.order.main.dao.OrderLogDAO;
import cn.tedu.luban.order.main.repository.OrderLogRepository;
import cn.tedu.luban.order.protocol.bo.OrderLogBO;
import cn.tedu.luban.order.protocol.dos.OrderLogDO;
import cn.tedu.luban.order.protocol.param.OrderLogParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class OrderLogRepositoryImpl implements OrderLogRepository {

    @Autowired
    private OrderLogDAO orderLogDAO;

    @Autowired
    private OrderLogConverter orderLogConverter;

    @Override
    public List<OrderLogBO> getOrderLogByOrderNo(String no) {
        //SELECT * FROM order_log where order_no =#{no}
        List<OrderLogDO> orderLogDOS = orderLogDAO.getOrderLogByOrderNo(no);

        return orderLogConverter.dos2bos(orderLogDOS);
    }

    @Override
    public void saveOrderLog(OrderLogParam param) {
        orderLogDAO.saveOrderLog(orderLogConverter.param2do(param));
    }
}
